#define _CRT_SECURE_NO_WARNINGS 1
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
#include<unordered_map>
using namespace std;

class Solution {
public:
    int minNumberOfFrogs(string croakOfFrogs) {
        string s = "croak";
        int hash[26] = { 0 };
        for (int i = 0; i < 5; i++) hash[s[i] - 'a'] = i;
        int hash1[26] = { 0 };
        for (auto& ch : croakOfFrogs)
        {
            if (ch == 'c')
            {
                if (hash1['k' - 'a'] != 0)
                {
                    hash1['k' - 'a']--;
                    hash1[ch - 'a']++;
                }
                else hash1[ch - 'a']++;
            }
            else
            {
                if (hash1[s[hash[ch - 'a'] - 1] - 'a'] == 0) return -1;
                hash1[s[hash[ch - 'a'] - 1] - 'a']--;
                hash1[ch - 'a']++;
            }
        }
        for (int i = 0; i < 4; i++)
        {
            if (hash1[s[i] - 'a'] != 0) return -1;
        }
        return hash1['k' - 'a'];
    }
};

int main() {
    int ret = Solution().minNumberOfFrogs("croakcroak");
    return 0;
}